<!DOCTYPE html>
<html lang="en">

<head>
	<meta charset="UTF-8">
	<meta http-equiv="X-UA-Compatible" content="IE=edge">
	<meta name="viewport" content="width=device-width, initial-scale=1.0">
	<title>Document</title>
</head>

<body>
	<script>
		const arr = [1, 2, 3]
		function fn() {
			let a = 0
			return {
				next: function () {
					return a < arr.length ? { value: arr[a++] } : { done: true }
				}
			}
		}
		const b = fn(arr)
		console.log(b.next())
		console.log(b.next())
		console.log(b.next())
		console.log(b.next())


		function fn1() {
			let a = 0
			return {
				next: function () {
					return { value: a++, done: false }
				}
			}
		}
		const c = fn1()
		console.log(c.next().value)
		console.log(c.next().value)
		console.log(c.next().value)
		console.log(c.next().value)
		console.log(c.next().value)
		console.log(c.next().value)
		console.log(c.next().value)
	</script>
</body>

</html>